<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>装饰者模式</title>
  </head>

  <body></body>
  <script>
    function wear() {
      console.log('穿上第一件衣服');
    }

    function decorator(decoratorTarget) {
      return function (...args) {
        console.log('穿上第二件衣服');
        if (!(decoratorTarget instanceof Function)) return;
        return decoratorTarget.apply(this, ...args);
      };
    }

    const wrapDecorator = decorator(wear);
    wrapDecorator();

  </script>
</html>
